#pragma once

#include <MeshVS_DataSource.hxx>
#include <Poly_Triangulation.hxx>
#include <TColStd_HArray2OfInteger.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <Precision.hxx>

// 自定义网格资源
class AMeshVS_DataSource : public MeshVS_DataSource
{
	DEFINE_STANDARD_RTTIEXT(AMeshVS_DataSource, MeshVS_DataSource)
public:
	AMeshVS_DataSource(const Handle(Poly_Triangulation)& plyTri);

	// 重载几何函数
	Standard_Boolean GetGeom(
		const Standard_Integer ID,
		const Standard_Boolean IsElement,
		TColStd_Array1OfReal& Coords,
		Standard_Integer& NbNodes,
		MeshVS_EntityType& Type) const Standard_OVERRIDE;

	// 重载几何类型函数
	Standard_Boolean GetGeomType(
		const Standard_Integer ID,
		const Standard_Boolean IsElement,
		MeshVS_EntityType& Type) const Standard_OVERRIDE;

	// 重载
	Standard_Address GetAddr(
		const Standard_Integer ID,
		const Standard_Boolean IsElement) const Standard_OVERRIDE;

	// 重载节点函数
	Standard_Boolean GetNodesByElement(
		const Standard_Integer ID,
		TColStd_Array1OfInteger& NodeIDs,
		Standard_Integer& NbNodes) const Standard_OVERRIDE;

	// 重载法向函数
	Standard_Boolean GetNormal(
		const Standard_Integer Id,
		const Standard_Integer Max,
		Standard_Real& nx,
		Standard_Real& ny,
		Standard_Real& nz) const Standard_OVERRIDE;

	const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE { return m_nodes; }
	const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE { return m_elements; }

private:
	TColStd_PackedMapOfInteger m_nodes;
	TColStd_PackedMapOfInteger m_elements;
	Handle(TColStd_HArray2OfInteger) m_elemNodes;
	Handle(TColStd_HArray2OfReal) m_nodeCoords;
	Handle(TColStd_HArray2OfReal) m_elemNormals;
};